package com.cy.pj.sys.util;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class PageUtil {
    public static <T>Page<T> startPage() {
        ServletRequestAttributes r = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = r.getRequest();

            String pageSizeStr = request.getParameter("pageSize");
            String pageCurrentStr = request.getParameter("pageCurrent");
            System.out.println("我被执行了   " + pageSizeStr);
            int pageSize = StringUtil.isEmpty(pageSizeStr) ? 1 : Integer.parseInt(pageSizeStr);
            int pageCurrent = StringUtil.isEmpty(pageCurrentStr) ? 5 : Integer.parseInt(pageCurrentStr);
            return PageHelper.startPage(pageSize, pageCurrent);


    }
 }

